package com.muki.wareHouse;

import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class RegularCore {

	private static final ConcurrentMap<String, ArrayList<String>> maps = new ConcurrentHashMap<>(); 
	
	public static void put(String topic,String regx) {
		ArrayList<String> regxs = maps.getOrDefault(topic, new ArrayList<>());
		regxs.add(regx);
		maps.put(topic, regxs);
	}
	
	public static boolean remove(String topic,String regx) {
		ArrayList<String> regxs = maps.getOrDefault(topic, null);
		if(regxs==null)
			return false;
		if(regxs.remove(regx))
			return true;
		return false;
		
	}
	
	public static ArrayList<String> getRegularsByTopic(String topic) {
		return maps.get(topic);
	}
	
	
}
